package com.sumainfor.pc.epc.controller.provider;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.pc.epc.service.impl.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author EddyChen
 * @Email 835033913@qq.com
 * @Create 2019/6/25 19:06
 */
@RestController
@RequestMapping("/key/provider/epc/search")
public class SearchController {

    @Autowired
    private SearchService service;

    /**
     * 工程部查询
     *
     * @param keyWord
     * @param roleId
     * @return
     */
    @PostMapping("/searchForEpc")
    public JsonResult searchForEpc(String keyWord, Integer roleId) {
        /**
         * 8	| 维修师傅
         * 5	| 工程经理
         * 6	| 工程助理
         * 7	| 采购专员
         */
        JsonResult result;
        switch (roleId) {
            case 8:
                result = service.searchForWs(keyWord);
                break;
            case 5:
                result = service.searchForGcJl(keyWord);
                break;
            case 6:
                result = service.searchForGcZl(keyWord);
                break;
            case 7:
                result = service.searchForCg(keyWord);
                break;
            default:
                result = JsonResult.error("没有这个类型的角色");
        }
        return result;
    }
}
